#include <stdio.h>
#include <fcntl.h>
#include "../../DeviceStatus.h"
#include "dbg.h"

int main(void){

 /* There is a string format vulnerability in DeviceStatus
  * .status just gets dumped directly to printk
  */
  DeviceStatus s =  {
   .status = "Hello, there"
  };

  int chall1 = open("/dev/k_challenge_1", O_RDWR);
  check(chall1 >= 0, "Error opening challenge device");

  int rc = write(chall1, &s, sizeof(DeviceStatus));
  check(rc >= 0, "Error writing to challenge device");
  /* We should see something like:
    <4>[ 1385.459589] Hello, there
    in dmesg
  */

  return 0;
error:
  return -1;
}
